package model;

import java.util.ArrayList;
import java.util.List;

import controller.DataBaseInteactor;

/**
 * 
 * @author Brendan Ng
 * @version
 *
 */

public class Author {
	private final String firstName;
	private final String lastName;
	private final String username;
	private final String password;
	
	private final DataBaseInteactor interactor;
	
	/**
	 * Create an author with the given first/last name, username and password.
	 * 
	 * @param theFirstName The author's first name
	 * @param theLastName The author's last name
	 * @param theUsername The author's username
	 * @param thePassword The author's password
	 * @param theInteractor The interactor
	 */
	public Author(String theFirstName, String theLastName, String theUsername, String thePassword,
			DataBaseInteactor theInteractor) {
		firstName = theFirstName;
		lastName = theLastName;
		username = theUsername;
		password = thePassword;
		interactor = theInteractor;
	}
	
	/**
	 * Create an author with the given username and password.
	 * The first/last names are initialized to be empty strings.
	 * 
	 * @param theUsername The author's username
	 * @param thePassword The author's password
	 * @param theInteractor The interactor
	 */
	public Author(String theUsername, DataBaseInteactor theInteractor) {
		username = theUsername;
		password = "";
		firstName = "";
		lastName = "";
		interactor = theInteractor;
	}
	
	/**
	 * Get the first name.
	 * @return The first name
	 */
	public String getFirstName() {
		return firstName;
	}
	
	/**
	 * Get the last name.
	 * @return The last name
	 */
	public String getLastName() {
		return lastName;
	}
	
	/**
	 * Get the username.
	 * @return The username
	 */
	public String getUsername() {
		return username;
	}
	
	/**
	 * Get the password.
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}
	
	/**
	 * Submit a manuscript to be reviewed.
	 * The author's name must be specified.
	 * 
	 * @param theAuthorUN The author username
	 * @param theConference The conference to be submitted under
	 * @param theManTitle The title of the manuscript to be submitted
	 * @param theAuthorField The author text field input
	 * @param theBody The body of the manuscript
	 * @return true if submit succeeded and false otherwise
	 */
	public boolean submit(String theAuthorUN, Conference theConference, String theManTitle,
						  String theAuthorField, String theBody) {
		return interactor.submitManuscript(theAuthorUN, theConference, theManTitle, theAuthorField, theBody);
	}
	
	/**
	 * Get the specified manuscript from the given conference.
	 * The author's name must be specified.
	 * 
	 * @param theAuthor The author of the manuscript
	 * @param theConference The conference to look under
	 * @param theTitle The title of the manuscript to look for
	 * @return The manuscript contents
	 */
	public String getManuscriptContents(Author theAuthor, Conference theConference, String theTitle) {
		return interactor.getManuscriptContents(theAuthor, theConference, theTitle);
	}

	/**
	 * Get the review(s) for the given manuscript
	 * The author's name must be specified.
	 * 
	 * @param theAuthor The author of the manuscript
	 * @param theConference The conference to look under
	 * @param theTitle The title of the manuscript
	 * @return A list of (the) review(s) for the given manuscript
	 */
	public ArrayList<String> getReviews(Author theAuthor, Conference theConference, String theTitle) {
		return interactor.getReviews(theAuthor, theConference, theTitle);
	}
	
	/**
	 * Remove the specified manuscript from the given conference.
	 * The author's name must be specified.
	 * 
	 * @param theAuthorUN The author's username
	 * @param theConference The conference to look under
	 * @param theManTitle The title of the manuscript to be removed
	 * @return True if removal is successful and false otherwise
	 */
	public boolean removeManuscript(String theAuthorUN, Conference theConference, String theManTitle) {
		return interactor.removeManuscript(theAuthorUN, theConference, theManTitle);
	}
}
